package flc.ast.fragment;

import android.Manifest;
import android.os.Bundle;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.blankj.utilcode.util.FragmentUtils;
import com.blankj.utilcode.util.PermissionUtils;
import com.blankj.utilcode.util.ToastUtils;
import com.huawei.hms.videoeditor.ui.mediapick.activity.MediaPickActivity;
import com.huawei.hms.videoeditor.ui.template.module.TemplateHomeFragment;

import java.util.List;

import flc.ast.R;
import flc.ast.databinding.FragmentSdkBinding;
import stark.common.basic.base.BaseNoModelFragment;
import stark.common.basic.event.EventStatProxy;
import stark.common.basic.utils.StatusBarUtils;
import stark.common.basic.utils.StkPermissionHelper;

/**
 * A simple {@link Fragment} subclass.
 * Use the {@link SdkFragment#newInstance} factory method to
 * create an instance of this fragment.
 */
public class SdkFragment extends BaseNoModelFragment<FragmentSdkBinding> {


    @Override
    protected int onCreate() {
        StatusBarUtils.setSystemStatusTextColor(false,getActivity());
        return R.layout.fragment_sdk;
    }


    @Override
    protected void initView() {
        EventStatProxy.getInstance().statEvent1(getActivity(), mDataBinding.event1Container);
        mDataBinding.rlStartWrite.setOnClickListener(this);
    }

    @Override
    protected void onClickCallback(View v) {
        switch (v.getId()){
            case R.id.rlStartWrite:
                getPermission();
                break;
        }
    }

    @Override
    protected void initData() {
        Fragment fragment = new TemplateHomeFragment();
        FragmentUtils.add(getChildFragmentManager(), fragment, R.id.flContainer);
    }

    //去到选择素材界面
    private void getPermission() {
        StkPermissionHelper.permission(StkPermissionHelper.Permission.ACCESS_IMAGE_VIDEO)
                .reqPermissionDesc(getString(R.string.get_storage_permission))
                .callback(new StkPermissionHelper.ACallback() {
                    @Override
                    public void onGranted() {
                        startActivity(MediaPickActivity.class);
                    }

                    @Override
                    public void onDenied(boolean needGoSettings) {
                        ToastUtils.showShort(getString(R.string.no_permission));
                    }
                }).request();
    }

}